// pages/home/home.js
Page({
  /**
   * 页面的初始数据
   */
  data: {
    cardCur: 0
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function () {
    this.query();
  },
  query() {
    // 调用云函数
    wx.cloud.callFunction({
      name: 'getHomeData',
      data: {},
      success: res => {
        console.log('[云函数] [getHomeData]: ', res.result.data);
        this.setData({
          info: res.result.data
        })
      },
      fail: err => {
        console.error('[云函数] [getWorks] 调用失败', err)
      }
    })
  },
  openPdf() {
    wx.navigateTo({
      url: '/pages/quotation/detail/index?id=cbddf0af60efb5b416ec89803804c874'
    })
  },
  // cardSwiper
  cardSwiper(e) {
    this.setData({
      cardCur: e.detail.current
    })
  },
  goto(e) {
    const url = e.currentTarget.dataset.path
    wx.navigateTo({
      url
    })
  },
  toServe(e) {
    const cur = e.currentTarget.dataset
    wx.navigateTo({
      url: `/pages/globalWedding/globalWedding?id=${cur.id}&name=${cur.name}`,
    })
  },
  callPhone() {
    wx.makePhoneCall({
      phoneNumber: this.data.info.mobile //仅为示例，并非真实的电话号码
    })
  },
  onShareAppMessage() {
    return {
      title: '华德培全球旅行婚礼'
    }
  }
})